const MarketKey = 'market'
const VendorKey = 'vendor'
const DashboardTypeKey = 'dashboardType'
const DateRangeKey = 'dateRange'
const Brand = 'brand'
const treeBrandKey = 'treeBrandKey'
const treeBrandJson = 'treeBrandJson'
const Category = 'category'
const treeCategoryKey = 'treeCategoryKey'
const treeCategoryJson = 'treeCategoryJson'
const IsCompare = 'IsCompare'
const ProductTagKey = 'productTag'
const TagConditionKey = 'tagCondition'
const MyReportCreatFormItemsDataKey = 'myReportCreatFormItemsData'
const Store = window.localStorage

export function getMarket() {
  return JSON.parse(Store.getItem(MarketKey))
}

export function setMarket(market) {
  return Store.setItem(MarketKey, JSON.stringify(market))
}
export function getVendor() {
  return JSON.parse(Store.getItem(VendorKey))
}

export function setVendor(vendor) {
  return Store.setItem(VendorKey, JSON.stringify(vendor))
}

export function getProductTag() {
  return JSON.parse(Store.getItem(ProductTagKey))
}

export function setProductTag(tag) {
  return Store.setItem(ProductTagKey, JSON.stringify(tag))
}
export function getTagCondition() {
  return JSON.parse(Store.getItem(TagConditionKey))
}

export function setTagCondition(tagCondition) {
  return Store.setItem(TagConditionKey, JSON.stringify(tagCondition))
}

export function getBrand() {
  return JSON.parse(Store.getItem(Brand))
}

export function setBrand(brand) {
  return Store.setItem(Brand, JSON.stringify(brand))
}

export function getCategory() {
  return JSON.parse(Store.getItem(Category))
}

export function setCategory(category) {
  return Store.setItem(Category, JSON.stringify(category))
}

export function getDashboardType() {
  return Store.getItem(DashboardTypeKey)
}
export function getTreeBrandKey() {
  return JSON.parse(Store.getItem(treeBrandKey))
}

export function setTreeBrandKey(brand) {
  return Store.setItem(treeBrandKey, JSON.stringify(brand))
}

export function getTreeCategoryKey() {
  return JSON.parse(Store.getItem(treeCategoryKey))
}

export function setTreeCategoryKey(category) {
  return Store.setItem(treeCategoryKey, JSON.stringify(category))
}

export function getTreeBrandJson() {
  return JSON.parse(Store.getItem(treeBrandJson))
}

export function setTreeBrandJson(brand) {
  return Store.setItem(treeBrandJson, JSON.stringify(brand))
}

export function getTreeCategoryJson() {
  return JSON.parse(Store.getItem(treeCategoryJson))
}

export function setTreeCategoryJson(category) {
  return Store.setItem(treeCategoryJson, JSON.stringify(category))
}

export function setDashboardType(dashboardType) {
  return Store.setItem(DashboardTypeKey, dashboardType)
}

export function getDateRange() {
  return JSON.parse(Store.getItem(DateRangeKey))
}

export function setDateRange(dateRange) {
  return Store.setItem(DateRangeKey, JSON.stringify(dateRange))
}

export function getIsCompare() {
  return Store.getItem(IsCompare)
}

export function setIsCompare(isCompare) {
  return Store.setItem(IsCompare, isCompare)
}

export function getMyReportCreatFormItemsDataStorage() {
  const myReportCreatFormItemsData = Store.getItem(
    MyReportCreatFormItemsDataKey
  )
  if (myReportCreatFormItemsData) {
    return JSON.parse(myReportCreatFormItemsData)
  }
}

export function setMyReportCreatFormItemsDataStorage(
  MyReportCreatFormItemsData
) {
  return Store.setItem(
    MyReportCreatFormItemsDataKey,
    JSON.stringify(MyReportCreatFormItemsData)
  )
}
